package com.xjc.controller.request;

import cn.hutool.json.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
 * <p>
 * Description
 * </p>
 *
 * @author xiaojincai
 * @since 2025-06-10
 */
@Data
@Schema(description = "模型请求参数")
public class ModelRequest implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 模型id
     */
    @Schema(description = "模型id")
    private String modelId;

    /**
     * 模型名称
     */
    @NotBlank(message = "模型名称不能为空")
    @Schema(description = "模型名称")
    private String name;

    /**
     * 模型分类
     */
    @Schema(description = "模型分类")
    private String category;

    /**
     * 模型描述
     */
    @Schema(description = "模型描述")
    private String description;

    /**
     * 流程定义xml
     */
    @NotBlank(message = "流程定义xml不能为空")
    @Schema(description = "流程定义xml")
    private String processDefXml;

    public String metadata(Integer version, String key) {
        final JSONObject request = new JSONObject();
        request.set("key", key);
        request.set("name", name);
        request.set("category", category);
        request.set("description", description);
        request.set("version", version);
        return request.toString();
    }
}
